package fightplan.actions;

import java.awt.event.ActionEvent;

import javax.swing.AbstractAction;
import javax.swing.JFrame;
import javax.swing.JOptionPane;

@SuppressWarnings("serial")
public class ExitAction extends AbstractAction {

	private JFrame frame;

	public ExitAction(JFrame frame) {
		super("Beenden");
		this.frame = frame;
	}

	public void actionPerformed(ActionEvent actionEvent) {
		exit(frame);
	}

	public static void exit(JFrame frame) {
		boolean confirm = JOptionPane.showConfirmDialog(frame, "Wollen Sie die Applikation wirklich beenden?",
				"Programm beenden?", JOptionPane.YES_NO_OPTION) == JOptionPane.OK_OPTION;
		if (!confirm)
			return;
		System.exit(0);
	}

}